package com.elephant.bean.selfBeanFactoryPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.core.annotation.Order;

/**
 * @author 林
 * @create 2025-05-27 15:43
 */
public class MyBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor  {

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		System.out.println("-------------------------------------------");
		System.out.println("postProcessBeanFactory-------MyBeanDefinitionRegistryPostProcessor");


	}

	@Override
	public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
		System.out.println("-------------------------------------------");
		System.out.println("postProcessBeanDefinitionRegistry-------MyBeanDefinitionRegistryPostProcessor");


		//在这里在整多一个BeanDefinitionRegistryPostProcessor对象
		BeanDefinitionBuilder builder=BeanDefinitionBuilder.rootBeanDefinition(MySelfBeanDefinitionRegistryPostProcessor.class);
		registry.registerBeanDefinition("myselfbeandefinitionregistrypostprocessor",builder.getBeanDefinition());
	}
}
